package com.tac.controller.mes;

import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.pojo.mes.Inspection;
import com.tac.service.mes.InspectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/inspection")
@Api(tags = "制作执行MES--质量管理--产品检验")
@CrossOrigin
public class InspectionController {

    @Autowired
    private InspectionService inspectionService;


    //产品检验查询
    @ApiOperation("产品检验查询")
    @GetMapping("/getList")
    public Result<PageInfo<Inspection>> getList(Integer pageNum, Integer pageSize, String serialNumber, String completionOrder, String planNumber, String jobName,
                                                String materialName, String inspectionLot,@DateTimeFormat(pattern = "yyyy-MM-dd") Date produceDateStart,@DateTimeFormat(pattern = "yyyy-MM-dd") Date produceDateEnd,
                                                String inspectionItems, String inspectionResults, String inspector,
                                                @DateTimeFormat(pattern = "yyyy-MM-dd") Date inspectionTimeStart,@DateTimeFormat(pattern = "yyyy-MM-dd") Date inspectionTimeEnd){
        return inspectionService.getList(pageNum,pageSize,serialNumber, completionOrder, planNumber, jobName, materialName, inspectionLot, produceDateStart, produceDateEnd, inspectionItems, inspectionResults,inspector,inspectionTimeStart,inspectionTimeEnd);
    }
    //产品检验添加
    @ApiOperation("产品检验添加")
    @PostMapping("/save")
    public Result save(@RequestBody  Inspection inspection){
        return inspectionService.save(inspection);
    }
    //产品检验删除
    @ApiOperation("产品检验删除")
    @DeleteMapping("/remove")
    public Result remove(@RequestBody  List<Integer> ids){
        return inspectionService.remove(ids);
    }
    //产品检验更新
    @ApiOperation("产品检验更新")
    @PutMapping("/update")
    public Result update(@RequestBody Inspection inspection){
        return inspectionService.update(inspection);
    }
}
